package ink.yql.util;

import java.io.Serializable;

/**
 * @author YQL
 * 用于前后端分离返回的容器
 */
public class RestObject implements Serializable{
    /**
     * 响应码
     */
    private String code;
    /**
     * 信息
     */
    private String message;
    /**
     * 响应的具体内容
     */
    private Object data;

    public RestObject(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public RestObject() {
    }

    public static RestObjectBuilder builder() {
        return new RestObjectBuilder();
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public Object getData() {
        return this.data;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof RestObject)) return false;
        final RestObject other = (RestObject) o;
        if (!other.canEqual((Object) this)) return false;
        final Object this$code = this.getCode();
        final Object other$code = other.getCode();
        if (this$code == null ? other$code != null : !this$code.equals(other$code)) return false;
        final Object this$message = this.getMessage();
        final Object other$message = other.getMessage();
        if (this$message == null ? other$message != null : !this$message.equals(other$message)) return false;
        final Object this$data = this.getData();
        final Object other$data = other.getData();
        if (this$data == null ? other$data != null : !this$data.equals(other$data)) return false;
        return true;
    }

    protected boolean canEqual(final Object other) {
        return other instanceof RestObject;
    }

    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $code = this.getCode();
        result = result * PRIME + ($code == null ? 43 : $code.hashCode());
        final Object $message = this.getMessage();
        result = result * PRIME + ($message == null ? 43 : $message.hashCode());
        final Object $data = this.getData();
        result = result * PRIME + ($data == null ? 43 : $data.hashCode());
        return result;
    }

    public String toString() {
        return "RestObject(code=" + this.getCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
    }

    public static class RestObjectBuilder {
        private String code;
        private String message;
        private Object data;

        RestObjectBuilder() {
        }

        public RestObject.RestObjectBuilder code(String code) {
            this.code = code;
            return this;
        }

        public RestObject.RestObjectBuilder message(String message) {
            this.message = message;
            return this;
        }

        public RestObject.RestObjectBuilder data(Object data) {
            this.data = data;
            return this;
        }

        public RestObject build() {
            return new RestObject(code, message, data);
        }

        public String toString() {
            return "RestObject.RestObjectBuilder(code=" + this.code + ", message=" + this.message + ", data=" + this.data + ")";
        }
    }
}
